import React, { useState, useEffect } from 'react';
import AbsentTable from '../../../compoennts/studentAbsent/AbsentTable';
import {Tag} from 'antd';
import service from '../../../services';
function CallList(props) {
    const [data, setData] = useState([]);
    

    const columns = [
        {
          title: '序号',
          dataIndex: 'id',
          key: 'id',
        },
        {
          title: '年级班级',
          dataIndex: 'className',
           key:'className'
        },
        {
          title: '学生姓名',
          dataIndex: 'student_name',
          key:'student_name'
        },
        {
          title: '性别',
          dataIndex: 'sex',
          key:'sex'
      },
      {
        title: '学籍号',
        dataIndex: 'sid',
        key:'sid'
      },
        {
          title: '今日考勤状态',
              dataIndex: 'state',
              key:'state',
          render: (_, { state }) => (
            <>
                  <Tag color={state==1?"green":"red"} key={state}>
                    {state==1?"正常":"迟到"}
                  </Tag>
            </>
          ),
        },
        {
          title: '电话号码',
          dataIndex: 'tel',
          key:'tel'
      },
        
      ];
    useEffect(() => {
        //获取请假学生列表的函数
        const getCallList = async () => {
            let result = await service.CallService.getAllCall()
            console.log(result.data)
            setData(result.data)
        }
        getCallList()
    }, [JSON.stringify(data)])

    return (
        <div>
           <div>
            
           </div>
            <AbsentTable columns={columns} data={data} rowKey={record => record.id}>
            </AbsentTable>

           
        </div >
    );
}

export default CallList;